<%--<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ include file="/layout/tag.jsp"%>
<script type="text/javascript">
	$(document).ready( 
		function() {
			//事件注册.
			$("#addBtn").click(addRow);
			$("a[name='deleteBtn']").each(
				function(index) {
					$(this).click(delRow);
				}
			);
			
			$("a[name='saveBtn']").each(
				function(index) {
					$(this).click(saveRow);
				}
			);
			
			//设置左菜单对应菜单CSS为选中状态.
			changeToActiveCss("menu_7025");
			
			//消息显示.
			var msg = '<c:out value="${msg}"/>';
			if (msg != "") {
				alert(msg);
			}
		}
	);
	
	function addRow() {
		var strTr = $("<tr><td><div class='buttons' style='float:left; margin-left:5px;'>" +
					"			<a name='deleteBtn'  href='#' title='开始日期大于等于系统日期,允许删除.'>删除</a>" +
					"			<a name='saveBtn' href='#' title='结束日期大于等于系统日期,允许保存.'>保存</a></div></td>" +
					"	<td><input type='text' name='name' style='width:120px; ' value=''/></td>" +
					"	<td><select name='period' style='width:100px;'>" + 
					<c:forEach var="periodItem" items="${periodList}" varStatus="status">
					"	<option value='${periodItem.itemValue}'>${periodItem.itemLabel}</option> "  +
					</c:forEach>
					"		</select></td> " +
					"	<td style='text-align:center;'><input type='text' name='fee' style='width:60px;' value=''/></td> " +
					"	<td style='text-align:center;'><input type='text' name='count' style='width:60px;' value=''/></td> " +
					"	<td style='text-align:center;'><input type='text' name='max' style='width:60px;' value=''/></td> " +
					"	<td style='text-align:center;'><input type='text' name='deposit' style='width:60px;' value=''/></td>" +
					"	<td style='text-align:center;'><input type='text' name='sort' style='width:60px;' value=''/></td><td></td></tr>");
						
		var tr = $("#editTable").append(strTr);
		$("a[name='deleteBtn']:last").click(delRow);
		$("a[name='saveBtn']:last").click(saveRow);
	}
	
	function delRow() { 	
		var sysId = $(this).parents("tr").attr("sysid");
		if (sysId != undefined && $.trim(sysId) != "") {
			$.ajax({
				type:"post",
				url:"${pageContext.request.contextPath}/system/deleteService.do",
				context:this,
				dataType:"json",
				data:"sysId=" + sysId,
				success:delCallBack,
				error:function(){alert("发生了错误.");},
			});
		} else {
			$(this).parents("tr").remove();
		}
	}
	
	function delCallBack(result) {
		if (result.status == "OK") {
			$(this).parents("tr").remove();
			alert(result.msg);
		} else {
			alert(result.msg);
		}
	}
	
	function saveRow() {
		var allObjs = $(this).parents("tr").find("*");
		var strData = "dummy=1";
		
		allObjs.each(function(){
			var tagName = this.tagName;
			if (tagName == "INPUT" || tagName == "SELECT") {
				strData += "&" + $(this).attr("name") + "=" + $(this).attr("value");
			}
		});
		
		$.ajax({
			type:"post",
			url:"${pageContext.request.contextPath}/system/saveService.do",
			context:this,
			dataType:"json",
			data:strData,
			success:saveCallBack,
			error:function(){alert("发生了错误.");},
		});
	}
	
	function saveCallBack(result) {
		alert(result.msg);
	}
</script>
<div id="content_right">
	<div style="width:100%;height:35px;line-height:35px;text-align:left;background-color:#F5FAFA;font-weight:bold; ">系统管理 > 全站设置 > 租书服务设置</div>
	<div>
		<div id="tabBar">
			<span class="curentTab">租书服务</span>
		</div>
	</div>
	<div id="editContainer">
		<div id="relationInfo" class="editPanel" style="float:left;height:320px; width:100%;">
			<div style="float:left; width:98%;margin-left:10px;height:92%;overflow-y:scroll;overflow-x:hidden;border:1px solid white;">
				<table id="editTable" class="relationTable">
					<tr>
						<th style="width:15%;">
							<div class="buttons" style="float:left; margin-left:5px;">
								<a id="addBtn" href="#">
									添加
								</a>
							</div>
						</th>
						<th style="width:13%;">
							服务类型
						</th>
						<th style="width:8%;">
							期间
						</th>
						<th style="width:7%;">
							会费
						</th>
						<th style="width:7%;">
							次数
						</th>
						<th style="width:7%;">
							本/次
						</th>
						<th style="width:7%;">
							服务</br>押金
						</th>
						<th style="width:7%;">
							排序
						</th>
						<th>
						</th>
					</tr>
					<c:forEach var="item" items="${serviceList}" varStatus="status">
					<tr sysid="${item.sysId}">
						<td>
							<div class="buttons" style="float:left; margin-left:5px;">
								<a name="deleteBtn" href="#" title="开始日期大于等于系统日期,允许删除.">
									删除
								</a>
								<a name="saveBtn" href="#" title="结束日期大于等于系统日期,允许保存.">
									保存
								</a>
							</div>
						</td>
						<td>
							<input type="hidden" name="sysId" value="<c:out value='${item.sysId}'/>"/>
							<input type="text" name="name" style="width:120px; " value="<c:out value='${item.name}'/>"/>
						</td>
						<td>
							<select name="period" style="width:100px; ">
							<c:forEach var="periodItem" items="${periodList}" varStatus="status">
							  <c:choose>
								<c:when test="${item.period == periodItem.itemValue}">
								<option value="${periodItem.itemValue}" selected>${periodItem.itemLabel}</option>
								</c:when>
								<c:otherwise>
								<option value="${periodItem.itemValue}">${periodItem.itemLabel}</option>
								</c:otherwise>
							  </c:choose>
							</c:forEach>
							</select>
						</td>
						<td style="text-align:center;">
							<input type="text" name="fee" style="width:60px; " value="<c:out value='${item.fee}'/>"/>
						</td>
						<td style="text-align:center;">
							<input type="text" name="count" style="width:60px; " value="<c:out value='${item.count}'/>"/>
						</td>
						<td style="text-align:center;">
							<input type="text" name="max" style="width:60px; " value="<c:out value='${item.max}'/>"/>
						</td>
						<td style="text-align:center;">
							<input type="text" name="deposit" style="width:60px; " value="<c:out value='${item.deposit}'/>"/>
						</td>
						<td style="text-align:center;">
							<input type="text" name="sort" style="width:60px; " value="<c:out value='${item.sort}'/>"/>
						</td>
						<td>
						</td>
					</tr>
					</c:forEach>
				</table>
				<div style="height:1px;clear:both;"></div>
			</div>
		</div>
		
	</div>
</div>
--%>